package com.ywjt.platformbusiness.store.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.util.TimeUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;


import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.amap.api.interfaces.IAMap;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.ywjt.platformbusiness.R;
import com.ywjt.platformbusiness.base.BaseActivity;

import com.ywjt.platformbusiness.common.UserData;
import com.ywjt.platformbusiness.constants.UrlConstants;
import com.ywjt.platformbusiness.http.HttpRequest;
import com.ywjt.platformbusiness.http.HttpStringCallBack;
import com.ywjt.platformbusiness.store.model.BusinessHomeInfoModel;
import com.ywjt.platformbusiness.store.model.ByYearModel;
import com.ywjt.platformbusiness.util.JsonUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import lecho.lib.hellocharts.gesture.ContainerScrollType;
import lecho.lib.hellocharts.gesture.ZoomType;
import lecho.lib.hellocharts.model.Axis;
import lecho.lib.hellocharts.model.AxisValue;
import lecho.lib.hellocharts.model.Line;
import lecho.lib.hellocharts.model.LineChartData;
import lecho.lib.hellocharts.model.PointValue;
import lecho.lib.hellocharts.model.ValueShape;
import lecho.lib.hellocharts.model.Viewport;
import lecho.lib.hellocharts.view.LineChartView;

public class BusinessManagementActivity extends BaseActivity implements View.OnClickListener {

   public static final Integer REQUESTCODE=10001;
    private LinearLayout llDetailInCome;
    public LineChartView lineChart;
    private TextView tvBalance,tvTodayMoney,tvTotalMoney,tvNewAddOrder;
    private LinearLayout llTimeSelect;
    private TextView tvTimeSelect;
    private LinearLayout llYear,llendTime;
    private TextView tvstarTime,tvendTime;
    private String starTime="",endTime="";

    private Integer status=0;//0 按年筛选 1 按月筛选 2 按周筛选 3 按天筛选
    public List<PointValue> mPointValues = new ArrayList<PointValue>();
    public List<AxisValue> mAxisXValues = new ArrayList<AxisValue>();
    private PopupWindow popupWindow;

    public static void actionStart(Context context) {
        Intent intent = new Intent(context, BusinessManagementActivity.class);
        context.startActivity(intent);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.llDetailInCome:
                //收支明细
                IncomeDetailActivity.actionStart(this);
                break;
            case R.id.llTimeSelect:
                showPopu(llTimeSelect);
                break;
            case R.id.llYear:
                //年份选择
                switch (status){
                    case 0:
                        TimePickerView startTime = new TimePickerBuilder(BusinessManagementActivity.this, new OnTimeSelectListener() {
                            @Override
                            public void onTimeSelect(Date date, View v) {//选中事件回调
                                SimpleDateFormat year=new SimpleDateFormat("yyyy");
                                tvstarTime.setText(year.format(date));
                                starTime=year.format(date);
                                getDataByYear();

                            }
                        })
                                .setType(new boolean[]{true, false, false, false, false, false})// 默认全部显示
                                .setCancelText("取消")//取消按钮文字
                                .isDialog(true)
                                .setSubmitText("确定")//确认按钮文字
                                .setTitleSize(18)//标题文字大小
                                .setTitleColor(getResources().getColor(R.color.white))
                                .setTitleText("选择时间")
                                .setContentTextSize(17)
                                .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                                .isCyclic(true)//是否循环滚动
                                .setTextColorOut(getResources().getColor(R.color.gray9))
                                .setTextColorCenter(getResources().getColor(R.color.red))
                                .setSubmitColor(getResources().getColor(R.color.white))//确定按钮文字颜色
                                .setLabel("年", "月", "日", "时", "分", "秒")//默认设���为年月日时分秒
                                .isCenterLabel(false) //是否只显示中间选中项的 label 文字，false 则每项 item 全部都带有 label。
                                .build();
                        startTime.show();
                        break;
                    case 1:
                        TimePickerView months = new TimePickerBuilder(BusinessManagementActivity.this, new OnTimeSelectListener() {
                            @Override
                            public void onTimeSelect(Date date, View v) {//选中事件回调
                                SimpleDateFormat month=new SimpleDateFormat("yyyy-MM");
                                tvstarTime.setText(month.format(date));
                                starTime=month.format(date);
                                getDataByMonth();

                            }
                        })
                                .setType(new boolean[]{true, true, false, false, false, false})// 默认全部显示
                                .setCancelText("取消")//取消按钮文字
                                .isDialog(true)
                                .setSubmitText("确定")//确认按钮文字
                                .setTitleSize(18)//标题文字大小
                                .setTitleColor(getResources().getColor(R.color.white))
                                .setTitleText("选择时间")
                                .setContentTextSize(17)
                                .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                                .isCyclic(true)//是否循环滚动
                                .setTextColorOut(getResources().getColor(R.color.gray9))
                                .setTextColorCenter(getResources().getColor(R.color.red))
                                .setSubmitColor(getResources().getColor(R.color.white))//确定按钮文字颜色
                                .setLabel("年", "月", "日", "时", "分", "秒")//默认设���为年月日时分秒
                                .isCenterLabel(false) //是否只显示中间选中项的 label 文字，false 则每项 item 全部都带有 label。
                                .build();
                        months.show();
                        break;
                    case 2:
                        Intent intent=new Intent(BusinessManagementActivity.this, ActivityWeekThisYear.class);
                        intent.putExtra("flag", REQUESTCODE);
                        startActivityForResult(intent, REQUESTCODE);
                        break;
                    case 3:
                            //开始时间已经选中
                            TimePickerView starTimes = new TimePickerBuilder(BusinessManagementActivity.this, new OnTimeSelectListener() {
                                @Override
                                public void onTimeSelect(Date date, View v) {//选中事件回调
                                    SimpleDateFormat month=new SimpleDateFormat("yyyy-MM-dd");
                                    tvstarTime.setText(month.format(date));
                                    starTime=month.format(date);
                                }
                            })
                                    .setType(new boolean[]{true, true, true, false, false, false})// 默认全部显示
                                    .setCancelText("取消")//取消按钮文字
                                    .isDialog(true)
                                    .setSubmitText("确定")//确认按钮文字
                                    .setTitleSize(18)//标题文字大小
                                    .setTitleColor(getResources().getColor(R.color.white))
                                    .setTitleText("选择时间")
                                    .setContentTextSize(17)
                                    .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                                    .isCyclic(true)//是否循环滚动
                                    .setTextColorOut(getResources().getColor(R.color.gray9))
                                    .setTextColorCenter(getResources().getColor(R.color.red))
                                    .setSubmitColor(getResources().getColor(R.color.white))//确定按钮文字颜色
                                    .setLabel("年", "月", "日", "时", "分", "秒")//默认设���为年月日时分秒
                                    .isCenterLabel(false) //是否只显示中间选中项的 label 文字，false 则每项 item 全部都带有 label。
                                    .build();
                            starTimes.show();
                        break;
                }

                break;
            case R.id.llendTime:
                TimePickerView endTimes = new TimePickerBuilder(BusinessManagementActivity.this, new OnTimeSelectListener() {
                    @Override
                    public void onTimeSelect(Date date, View v) {//选中事件回调
                        SimpleDateFormat month=new SimpleDateFormat("yyyy-MM-dd");
                        tvendTime.setText(month.format(date));
                        endTime=month.format(date);
                        getDataByDay();
                    }
                })
                        .setType(new boolean[]{true, true, true, false, false, false})// 默认全部显示
                        .setCancelText("取消")//取消按钮文字
                        .isDialog(true)
                        .setSubmitText("确定")//确认按钮文字
                        .setTitleSize(18)//标题文字大小
                        .setTitleColor(getResources().getColor(R.color.white))
                        .setTitleText("选择时间")
                        .setContentTextSize(17)
                        .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                        .isCyclic(true)//是否循环滚动
                        .setTextColorOut(getResources().getColor(R.color.gray9))
                        .setTextColorCenter(getResources().getColor(R.color.red))
                        .setSubmitColor(getResources().getColor(R.color.white))//确定按钮文字颜色
                        .setLabel("年", "月", "日", "时", "分", "秒")//默认设���为年月日时分秒
                        .isCenterLabel(false) //是否只显示中间选中项的 label 文字，false 则每项 item 全部都带有 label。
                        .build();
                endTimes.show();
                break;
        }
    }

    public void showPopu(View view){
        View inflate = LayoutInflater.from(BusinessManagementActivity.this).inflate(R.layout.popuwindow_time_select,null);
        TextView tvYear=inflate.findViewById(R.id.tvYear);
        TextView tvMonth=inflate.findViewById(R.id.tvMonth);
        TextView tvWeek=inflate.findViewById(R.id.tvWeek);
        TextView tvDay=inflate.findViewById(R.id.tvDay);
        tvYear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                status=0;
                tvTimeSelect.setText("按年筛选");
                llendTime.setVisibility(View.GONE);
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy");
                starTime=simpleDateFormat.format(System.currentTimeMillis());
                tvstarTime.setText(simpleDateFormat.format(System.currentTimeMillis()));
                popupWindow.dismiss();
                getDataByYear();
         }
        });
        tvMonth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tvTimeSelect.setText("按月筛选");
                llendTime.setVisibility(View.GONE);
                status=1;
                popupWindow.dismiss();
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM");
                starTime=simpleDateFormat.format(System.currentTimeMillis());
                tvstarTime.setText(simpleDateFormat.format(System.currentTimeMillis()));
                getDataByMonth();
            }
        });
        tvWeek.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                status=2;
                tvTimeSelect.setText("按周筛选");
                llendTime.setVisibility(View.GONE);
                popupWindow.dismiss();
                Intent intent=new Intent(BusinessManagementActivity.this, ActivityWeekThisYear.class);
                intent.putExtra("flag", REQUESTCODE);
                startActivityForResult(intent, REQUESTCODE);
            }
        });
        tvDay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                status=3;
                tvTimeSelect.setText("按日筛选");
                llendTime.setVisibility(View.VISIBLE);
                popupWindow.dismiss();
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
                starTime=simpleDateFormat.format(System.currentTimeMillis());
                endTime=simpleDateFormat.format(System.currentTimeMillis());
                tvstarTime.setText(starTime);
                tvendTime.setText(endTime);
                getDataByDay();
            }
        });
        popupWindow = new PopupWindow(inflate, RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        //设置背景,这个没什么效果，不添加会报错
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        //设置点击弹窗外隐藏自身
        popupWindow.setFocusable(true);
        popupWindow.setOutsideTouchable(true);
        //相对于某一个控件的位置
        popupWindow.showAsDropDown(view,0,0);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.business_management_activity;
    }

    @Override
    protected void initView() {
        setTitleText("营业数据");
        llDetailInCome=findViewById(R.id.llDetailInCome);
        llDetailInCome.setOnClickListener(this::onClick);
        tvNewAddOrder=findViewById(R.id.tvNewAddOrder);
        tvBalance=findViewById(R.id.tvBalance);
        tvstarTime=findViewById(R.id.tvYear);
        tvendTime=findViewById(R.id.tvendTime);
        llYear=findViewById(R.id.llYear);
        tvTodayMoney=findViewById(R.id.tvTodayMoney);
        llTimeSelect=findViewById(R.id.llTimeSelect);
        tvTimeSelect=findViewById(R.id.tvTimeSelect);
        tvTotalMoney=findViewById(R.id.tvTotalMoney);
        llendTime=findViewById(R.id.llendTime);
        lineChart = (LineChartView) findViewById(R.id.chart);
        llTimeSelect.setOnClickListener(this::onClick);
        llYear.setOnClickListener(this::onClick);
        llendTime.setOnClickListener(this::onClick);

        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy");
        starTime=simpleDateFormat.format(System.currentTimeMillis());
        getCenterData();
        getDataByYear();

    }

    /**
     * 设置X 轴的显示
     */
    private void getAxisXLables(List<ByYearModel.ResultDTO> data) {
        for (int i = 0; i < data.size(); i++) {
            mAxisXValues.add(new AxisValue(i).setLabel(data.get(i).getDate()));
            mPointValues.add(new PointValue(i, data.get(i).getMoney()));
        }
    }

    private void initLineChart(List<ByYearModel.ResultDTO> datas) {
        mAxisXValues.clear();
        mPointValues.clear();
        getAxisXLables(datas);

        Line line = new Line(mPointValues).setColor(Color.parseColor("#1E90FF"));  //折线的颜色（蓝色）
        List<Line> lines = new ArrayList<Line>();
        line.setShape(ValueShape.CIRCLE);//折线图上每个数据点的形状
        line.setCubic(false);//曲线是否平滑，即是曲线还是折线
        line.setFilled(false);//是否填充曲线的面积
        line.setHasLabels(true);//曲线的数据坐标是否加上备注
        line.setColor(Color.RED);
        line.setStrokeWidth(1);//线条的粗细，默认是3
        line.setHasLines(true);//是否用线显示。如果为false 则没有曲线只有点显示
        line.setHasPoints(false);//是否显示圆点 如果为false 则没有原点只有点显示（每个数据点都是个大的圆点）
        lines.add(line);
        LineChartData data = new LineChartData();
        data.setLines(lines);

        //坐标轴
        Axis axisX = new Axis(); //X轴
        axisX.setHasTiltedLabels(false);  //X坐标轴字体是斜的显示还是直的，true是斜的显示
        axisX.setTextColor(Color.BLACK);  //设置字体颜色
        axisX.setName("单位/日");  //表格名称
        axisX.setTextSize(10);//设置字体大小
        //axisX.setMaxLabelChars(8); //最多几个X轴坐标
        axisX.setValues(mAxisXValues);  //填充X轴的坐标名称
        data.setAxisXBottom(axisX); //x 轴在底部
        axisX.setHasLines(false); //x 轴分割线
        // Y轴是根据数据的大小自动设置Y轴上限
        Axis axisY = new Axis();  //Y轴
        axisY.setName("单位/元");//y轴标注
        axisY.setTextColor(Color.BLACK);
        axisY.setTextSize(10);//设置字体大小
        data.setAxisYLeft(axisY);  //Y轴设置在左边
        //设置行为属性，支持缩放、滑动以及平移
        lineChart.setInteractive(true);
        lineChart.setZoomType(ZoomType.HORIZONTAL);
        lineChart.setMaxZoom((float) 3);//最大方法比例
        lineChart.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
        lineChart.setLineChartData(data);
        lineChart.setVisibility(View.VISIBLE);
        Viewport v = new Viewport(lineChart.getMaximumViewport());
        v.bottom = 0;
     //   v.top = maxY;
        //固定Y轴的范围,如果没有这个,Y轴的范围会根据数据的最大值和最小值决定,这不是我想要的
        lineChart.setMaximumViewport(v);
        v.left = datas.size()-datas.size();
        v.right = datas.size()-1;
        lineChart.setCurrentViewport(v);
    }


    @Override
    protected void initData() { }

    @Override
    protected int getTitleBarType() {
        return 0;
    }

    private void getCenterData() {
        new HttpRequest(getContext()).doPost(UrlConstants.merchant_information+
                UserData.create(getContext()).get(UserData.MERCHANTID), "", new HttpStringCallBack() {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onSuccess(Object result) {
                try {
                    String data = result.toString();
                    //把请求得数据转换成json对象
                    JSONObject jsonObject = null;
                    jsonObject = new JSONObject(data);
                    String message = jsonObject.getString("message");
                    Boolean success=jsonObject.getBoolean("success");
                    if(success){
                        Object obj = JsonUtils.fromJson(result.toString(), BusinessHomeInfoModel.class);
                        if (obj instanceof BusinessHomeInfoModel) {
                            BusinessHomeInfoModel model = (BusinessHomeInfoModel) obj;
                            tvBalance.setText(model.getResult().getBalance()+"");
                            tvTodayMoney.setText(model.getResult().getTodayDealRental()+"");
                            tvTotalMoney.setText(model.getResult().getDealRental()+"");
                            tvNewAddOrder.setText(model.getResult().getNewOrderNum()+"");
                        }
                    }else {
                        Toast.makeText(getContext(),message,Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(int code, String msg) {
                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
            }
        });
    }
    //按年
    private void getDataByYear() {
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("starTime",starTime);
            jsonObject.put("shopId",
                    UserData.create(BusinessManagementActivity.this).get(UserData.MERCHANTID));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        new HttpRequest(getContext()).doPost(UrlConstants.merchantg_etRevenueDataByYear, "", jsonObject,new HttpStringCallBack() {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onSuccess(Object result) {
                try {
                    String data = result.toString();
                    //把请求得数据转换成json对象
                    JSONObject jsonObject = null;
                    jsonObject = new JSONObject(data);
                    String message = jsonObject.getString("message");
                    Boolean success=jsonObject.getBoolean("success");
                    if(success){
                        Object obj = JsonUtils.fromJson(result.toString(), ByYearModel.class);
                        if (obj instanceof ByYearModel) {
                            ByYearModel model = (ByYearModel) obj;
                            initLineChart(model.getResult());
                        }
                    }else {
                        Toast.makeText(getContext(),message,Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(int code, String msg) {
                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
            }
        });
    }
    //按月
    private void getDataByMonth() {
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("starTime",starTime);
            jsonObject.put("shopId",
                    UserData.create(BusinessManagementActivity.this).get(UserData.MERCHANTID));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        new HttpRequest(getContext()).doPost(UrlConstants.merchant_getRevenueDataByMonth, "", jsonObject,new HttpStringCallBack() {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onSuccess(Object result) {
                try {
                    String data = result.toString();
                    //把请求得数据转换成json对象
                    JSONObject jsonObject = null;
                    jsonObject = new JSONObject(data);
                    String message = jsonObject.getString("message");
                    Boolean success=jsonObject.getBoolean("success");
                    if(success){
                        Object obj = JsonUtils.fromJson(result.toString(), ByYearModel.class);
                        if (obj instanceof ByYearModel) {
                            ByYearModel model = (ByYearModel) obj;
                           initLineChart(model.getResult());
                        }
                    }else {
                        Toast.makeText(getContext(),message,Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(int code, String msg) {
                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
            }
        });
    }
    //按周
    private void getDataByWeek() {
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("starTime",starTime);
            jsonObject.put("shopId",
                    UserData.create(BusinessManagementActivity.this).get(UserData.MERCHANTID));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        new HttpRequest(getContext()).doPost(UrlConstants.merchant_getRevenueDataByWeek, "", jsonObject,new HttpStringCallBack() {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onSuccess(Object result) {
                try {
                    String data = result.toString();
                    //把请求得数据转换成json对象
                    JSONObject jsonObject = null;
                    jsonObject = new JSONObject(data);
                    String message = jsonObject.getString("message");
                    Boolean success=jsonObject.getBoolean("success");
                    if(success){
                        Object obj = JsonUtils.fromJson(result.toString(), ByYearModel.class);
                        if (obj instanceof ByYearModel) {
                            ByYearModel model = (ByYearModel) obj;
                            initLineChart(model.getResult());
                        }
                    }else {
                        Toast.makeText(getContext(),message,Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(int code, String msg) {
                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
            }
        });
    }

    //按日
    private void getDataByDay() {
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("starTime",starTime);
            if (endTime.equals("")){
                Toast.makeText(BusinessManagementActivity.this,"请先选择截止时间！！",Toast.LENGTH_SHORT).show();
                        return;
            }
            jsonObject.put("endTime",endTime);
            jsonObject.put("shopId",
                    UserData.create(BusinessManagementActivity.this).get(UserData.MERCHANTID));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        new HttpRequest(getContext()).doPost(UrlConstants.merchant_getRevenueDataByDay, "", jsonObject,new HttpStringCallBack() {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onSuccess(Object result) {
                try {
                    String data = result.toString();
                    //把请求得数据转换成json对象
                    JSONObject jsonObject = null;
                    jsonObject = new JSONObject(data);
                    String message = jsonObject.getString("message");
                    Boolean success=jsonObject.getBoolean("success");
                    if(success){
                        Object obj = JsonUtils.fromJson(result.toString(), ByYearModel.class);
                        if (obj instanceof ByYearModel) {
                            ByYearModel model = (ByYearModel) obj;
                            initLineChart(model.getResult());
                        }
                    }else {
                        Toast.makeText(getContext(),message,Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(int code, String msg) {
                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
            }
        });
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode==RESULT_OK){
            if (requestCode==REQUESTCODE){
                starTime=data.getStringExtra("starTime");
                tvstarTime.setText(data.getStringExtra("starTime"));
                getDataByWeek();
            }
        }
    }
}